package com.xique.park.bean.transform.web.garageLaneDev;

import com.xique.common.core.utils.SecurityUtils;
import com.xique.park.bean.domain.ParkDeviceNew;
import com.xique.park.bean.domain.ParkLane;
import com.xique.park.bean.request.web.garageLaneDev.subdev.AddSubDevRequest;
import com.xique.park.bean.request.web.garageLaneDev.subdev.EditSubDevRequest;
import com.xique.park.bean.vo.web.garageLaneDeviceTree.TreeNodeSubIpcVo;

import java.util.Date;

/**
 * 副相机转化类
 *
 * @author xique
 */
public class SubIpcTransform {

    public static TreeNodeSubIpcVo transformNodeSubIpcVo(ParkDeviceNew parkDeviceIpcSub, ParkLane parkLane) {
        TreeNodeSubIpcVo treeIpcVo = new TreeNodeSubIpcVo();
        treeIpcVo.setLaneId(parkDeviceIpcSub.getLaneId());
        treeIpcVo.setLaneName(parkLane.getName());
        treeIpcVo.setName(parkDeviceIpcSub.getName());
        treeIpcVo.setDevCode(parkDeviceIpcSub.getCode());
        treeIpcVo.setIp(parkDeviceIpcSub.getIp());
        treeIpcVo.setStatus(parkDeviceIpcSub.getStatus());
        treeIpcVo.setSort(null != parkDeviceIpcSub.getSort() ? parkDeviceIpcSub.getSort() : 1L);
        treeIpcVo.setType("ipc-sub");
        treeIpcVo.setModel(parkDeviceIpcSub.getModel());
        treeIpcVo.setCreateTime(parkDeviceIpcSub.getCreateTime());
        treeIpcVo.setUpdateTime(parkDeviceIpcSub.getUpdateTime());
        return treeIpcVo;
    }

    /**
     * 添加副相机request转化为parkDeviceNew实体
     */
    public static ParkDeviceNew transformAddSubIpcRequest(AddSubDevRequest request) {
        ParkDeviceNew parkDeviceNew = new ParkDeviceNew();
        parkDeviceNew.setParkId(SecurityUtils.getParkId());
        parkDeviceNew.setStatus(request.getStatus());
        parkDeviceNew.setName(request.getName());
        parkDeviceNew.setLaneId(request.getLaneId());
        parkDeviceNew.setCode(request.getDevCode());
        parkDeviceNew.setIp(request.getIp());
        parkDeviceNew.setIsMain("N");
        parkDeviceNew.setModel(request.getModel());
        parkDeviceNew.setSort(request.getSort());
        parkDeviceNew.setType(request.getType());
        parkDeviceNew.setUpdateTime(new Date());
        parkDeviceNew.setUpdateUser(SecurityUtils.getUserId());
        return parkDeviceNew;
    }

    /**
     * 编辑副相机request转化为parkDeviceNew实体
     */
    public static ParkDeviceNew transformEditSubIpcRequest(EditSubDevRequest request) {
        ParkDeviceNew parkDeviceNew = new ParkDeviceNew();
        parkDeviceNew.setId(request.getId());
        parkDeviceNew.setParkId(SecurityUtils.getParkId());
        parkDeviceNew.setStatus(request.getStatus());
        parkDeviceNew.setName(request.getName());
        parkDeviceNew.setLaneId(request.getLaneId());
        parkDeviceNew.setCode(request.getDevCode());
        parkDeviceNew.setIp(request.getIp());
        parkDeviceNew.setIsMain("N");
        parkDeviceNew.setModel(request.getModel());
        parkDeviceNew.setSort(request.getSort());
        return parkDeviceNew;
    }
}
